﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace TeF.Runner.Extensions
{
    internal static class TypeExtensions
    {
        public static IEnumerable<MethodInfo> GetTestMethods<TAttribute>(this Type type)
            where TAttribute : Attribute
        {
            if (type == null)
                throw new ArgumentNullException("type");

            return
                type.GetMethods()
                    .Where(m =>
                           m.IsPublic &&
                           !m.IsStatic &&
                           !m.IsAbstract &&
                           m.HasAttribute<TAttribute>());
        }
    }
}
